package com.pet.server.dao.common;

import com.pet.framework.dao.util.TemplateDao;
import com.pet.framework.page.Page;
import com.pet.server.po.PetAdopt;
import com.pet.server.po.PetAdoptItem;
import com.pet.server.po.PetInfo;
import com.pet.server.po.PetMissing;
import com.pet.server.po.PetSay;
import com.pet.server.po.PetTimeLine;
import com.pet.system.statement.Statement;

public class PetDao extends TemplateDao {

	
	
	public void searchPet(PetSay petSay,Page page) {
     	   Statement stms = stmsFactory.createStatement(" from PetSay p where 1=1 and  state!=4");
     				 if(null!=petSay){
     			     	  stms.append("and", "p.petCate", "=", petSay.getPetCate());
     			     	  stms.appendLike(null, "and", "p.title", petSay.getTitle());
     			      }
     	             stms.addOrderBy("p.id desc");
     	   templateDao.search(stms, page);	
	}
	public void searchPetMissing(PetMissing petMissing,Page page) {
		 Statement stms = stmsFactory.createStatement(" from PetMissing p where 1=1 and  state!=4");
			 if(null!=petMissing){
		     	  stms.append("and", "p.petCate", "=", petMissing.getPetCate());
		     	  stms.appendLike(null, "and", "p.phone", petMissing.getPhone());
		      }
          stms.addOrderBy("p.id desc");
          	templateDao.search(stms, page);	
	}

	
	public void searchPetAdopt(PetAdopt petAdopt, Page page) {
		Statement stms = stmsFactory.createStatement(" from PetAdopt p where 1=1 and  state!=4");
		 if(null!=petAdopt){
			 stms.append("and", "p.petCate", "=", petAdopt.getPetCate());
	     	  stms.append("and", "p.phone", "=", petAdopt.getPhone());
	     	  stms.appendLike(null, "and", "p.user_id", petAdopt.getUserId());
	      }
		 stms.addOrderBy("p.id desc");
     	templateDao.search(stms, page);	
	}

	
	public void searchPetAdoptItem(PetAdoptItem petAdoptItem, Page page) {
		Statement stms = stmsFactory.createStatement(" from PetAdoptItem p where 1=1 and  state!=4");
		 if(null!=petAdoptItem){
	     	  stms.append("and", "p.phone", "=", petAdoptItem.getPhone());
	     	  stms.appendLike(null, "and", "p.user_id", petAdoptItem.getUserId());
	      }
		 stms.addOrderBy("p.id desc");
     	templateDao.search(stms, page);	
	}
	
	
	public void searchPetInfo(PetInfo petInfo, Page page) {
		
		Statement stms = stmsFactory.createStatement(" from PetInfo p where 1=1 and state!=4");
		 if(null!=petInfo){
	     	  stms.append("and", "p.pet_name", "=", petInfo.getPetName());
	     	  stms.appendLike(null, "and", "p.user_id", petInfo.getUserId());
	      }
         stms.addOrderBy("p.id desc");
         templateDao.search(stms, page);	
	}
	
	
	public void searchPetTimeLine(PetTimeLine petTimeLine, Page page) {
		Statement stms = stmsFactory.createStatement(" from PetTimeLine p where 1=1 and state!=4");
		 if(null!=petTimeLine){
	     	  stms.append("and", "p.pet_id", "=", petTimeLine.getPetId());
	     	  stms.appendLike(null, "and", "p.user_id", petTimeLine.getUserId());
	      }
        stms.addOrderBy("p.id desc");
        templateDao.search(stms, page);	
	}

}
